PRA5: Tom and Jerry! // Advanced

 
Jerry and Tom's never ending struggle has reached its climax with the arrival of Tom's mom, a legendary mouse catcher known by all. The three of them are locked in the location housing the final battle, an N by M size rectangular pit of doom. Their chase is occurring in the rectangular pit of doom occurs in a somewhat civilized turn by turn manner. Specifically, Jerry moves, then both cats move. In each move Jerry, Tom, and his mom can move only one square vertically or horizontally. If Jerry is located at the edge of the pit then in his next move he can jump off the field and is saved from Tom and his mom. If in the next move one of the cats moves to the pit location with Jerry then there is no escape for Jerry.

Given Jerry, Tom, and his mom's respective initial positions determine if there is a way for Jerry to escape the cats. Jerry is the first to make his move.

Input Format

In the first line of input two integers N and M are given, not exceeding 100, where N is the number of rows while M is the number of columns. The second line contains a number k [k <= 10], which defines the number of test cases for the given rectangular pit of doom. In the next k lines the initial positions of Jerry and the cats are given. The position in the field is given by two numbers: the first is the number of the row, the second is the number of the column. The first two integers are the coordinates of Jerry, the next four integers are the coordinates of the cats. The rows and columns begin counting at 1.

Sample Input

5 3
1
2 2 1 1 3 3

Output Format

You must output k lines with answers for each test case. Print out 1 if Jerry can escape or 0 otherwise, skipping lines between each 0 or 1.

Sample Output

0




You must be logged in to submit a solution.